package com.springboot.admin.exception;

import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.bind.annotation.ExceptionHandler;

/************************************************************************
 *
 *    Copyright  Copyright 2021 Google Inc.
 *    File Name: GlobalExceptionHandler
 *    Description: 处理整个web controller的异常
 *
 *    Version: V1.0
 *    Author: Fuc
 *    Create Time: 2021-01-08
 *
 *************************************************************************/
@Slf4j
@ControllerAdvice
public class GlobalExceptionHandler {

  @ExceptionHandler({ArithmeticException.class, NullPointerException.class}) // 处理异常
  public String handleArithException(Exception e) {

    log.error("异常是：{}", e);
    return "login"; // 视图地址
  }

}
